/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pv168.reminder.swing.workers;

import cz.muni.fi.pv168.reminder.entities.Worker;
import cz.muni.fi.pv168.reminder.managers.WorkerManager;
import cz.muni.fi.pv168.reminder.managers.implementation.WorkerManagerImpl;
import cz.muni.fi.pv168.reminder.swing.FrameMainWindow;
import javax.swing.SwingWorker;

/**
 *
 * @author Katarína
 */
public class GetWorkerSwingWorker extends SwingWorker<Worker, Void> {
        Long ID;
        
        public GetWorkerSwingWorker(Long workerID) {
            ID = workerID;
        }

        @Override
        protected Worker doInBackground() throws Exception {
            Worker worker = null;            
            WorkerManager workerManager = new WorkerManagerImpl();            

            workerManager.setDataSource(FrameMainWindow.getDataSource());

            worker = workerManager.findPersonById(ID);
            
            return worker;
        }
    }